
<style>
.red{color:red;}
</style>
<div>


关键字：<input type="text" id="keyword" value="" />&nbsp;&nbsp;
<input type="submit" id="search" value="search">
</div>

<div>
	<div>
		<h2>分类：</h2>
		<p id="ftypeList">
		   
				
		  
		   		</p>
		<p id="catList">
			 	
				
		   
		   		</p>
		
	</div>
	<div>
		<h2>品牌：</h2>
		<p id="brandList">
		   
		   		</p>

	</div>
</div>

<div id="list">

    <table align="left" border="1" width="100%">
	    		<tr>
			<td><pre>啊手动阀手动阀、
</td>
		</tr>
		
	</table>
</div>

<div id="pagenav">
	<div id="pagenav"><a href="">首页</a>&nbsp;<a href="">上一页</a>&nbsp;<a class="red" href="">1</a>&nbsp;<a href="">下一页</a>&nbsp;<a href="">未页</a></div></div>
<script src="/mvc/Static/js/jquery-1.10.1.min.js"></script>
<script>
var cat_id = 0;
var keyword='';
var brand_id = 0;
var page = 1;

$(function(){
		
	$.ajax({
		url:"/mvc/index.php/Home/index/ajax_brand_list",
		type:"post",
		dataType:"json",
		success:function(obj){
			if(obj.code<0){
				alert(obj.message);
			}else{
				$("#brandList").html(obj.data);
			}
		}

	});
	$.ajax({
		url:"/mvc/index.php/Home/index/ajax_ftype_list",
		type:"post",
		dataType:"json",
		success:function(obj){
			if(obj.code<0){
				alert(obj.message);
			}else{
				$("#ftypeList").html(obj.data);
			}
		}
	});
	
	$("#brandList").on("click","a",function(){
		var myid = $(this).attr("myid");
		brand_id = myid ;
		page = 1;
		$(this).addClass("red"). siblings().removeClass("red");
		searchGoods();
	});
	$("#ftypeList").on("click","a",function(){
		var myid = $(this).attr("myid");
		if(myid){
			$.ajax({
				url:"/mvc/index.php/Home/index/ajax_cat_list",
				type:"post",
				data:{" ftype":myid },
				dataType:"json",
				success:function(obj){
					if(obj.code<0){
						alert(obj.message);
					}else{
						$("#catList").html(obj.data);
					}
				}
			});
		}
		$(this).addClass("red"). siblings().removeClass("red");
	});

	$("#catList").on("click","a",function(){
		$(this).addClass("red"). siblings().removeClass("red");
		var myid = $(this).attr("myid");
		cat_id = myid;
		page =1;
		searchGoods();
	});
	$("#pagenav").on("click","a",function(){
		var mypage = $(this).attr("mypage");
		page = mypage;
		searchGoods();
		

	});
	//search btn
	$("#search").click(function(){
		keyword = $("#keyword").val();
		brand_id=0;
		cat_id = 0 ;
		page =1 ;
		searchGoods();
	});
});

function searchGoods(){
	//查询数据
		$.ajax({
			url:"/mvc/index.php/Home/index/ajax_goods_list",
			type:"post",
			data:{"page":page,"cat_id":cat_id,"keyword":keyword,"brand_id":brand_id},
			dataType:"json",
			success:function(obj){
				if(obj.code<0){
					alert(obj.message);
				}else{

					$("#list").html(obj.data.list);
					$("#pagenav").html(obj.data.navstr);
				}
			}
		});
}
</script>